/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.login;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.qihoo.gamecenter.sdk.login.plugin.h.e;
import com.qihoo.gamecenter.sdk.login.plugin.h.g;
import org.json.JSONObject;

public class a {
    private boolean a;
    private Context b;
    private static a c;

    private a(Context paramContext) {
        this.b = paramContext;
        this.a = false;
    }

    public static a a(Context paramContext) {
        if (null == c)
            c = new a(paramContext);
        return c;
    }

    public void a() {
        if (this.a)
            return;
        if (null == this.b)
            return;
        ConnectivityManager localConnectivityManager = (ConnectivityManager) this.b.getSystemService("connectivity");
        NetworkInfo localNetworkInfo = localConnectivityManager.getActiveNetworkInfo();
        if ((localNetworkInfo != null) && (localNetworkInfo.isAvailable())) {
            int i = localNetworkInfo.getType();
            if (i != 1)
                return;
        }
        if (!(b()))
            return;
        new Thread(new Runnable() {
            public void run() {
                a.a(a.this, true);
                long l1 = System.currentTimeMillis();
                String str = com.qihoo.gamecenter.sdk.login.plugin.d.a.a(a.a(a.this),
                        "http://openboxcdn.mobilem.360.cn/html/gamecenter/zssdkver.json?time=" + Long.toString(l1));
                if (null != str)
                    try {
                        JSONObject localJSONObject = new JSONObject(str);
                        int i = localJSONObject.getInt("minver");
                        g.a(a.a(a.this), "appstore_service_min_ver", i);
                        long l2 = System.currentTimeMillis();
                        g.a(a.a(a.this), "appstore_service_min_ver_ts", Long.toString(l2));
                    } catch (Exception localException) {
                        e.b("AppStoreMinVerUpdater", "run error!", localException);
                    }
                a.a(a.this, false);
            }
        }).start();
    }

    private boolean b() {
        long l1 = System.currentTimeMillis();
        String str = g.d(this.b, "appstore_service_min_ver_ts");
        long l2 = 0L;
        if (!(str.equals(""))) {
            l2 = 0L;
            try {
                l2 = Long.parseLong(str);
            } catch (Exception localException) {}
        }
        return ((l1 - l2) / 1000L >= 5184000L);
    }
}